<%@ page isELIgnored="false" language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<c:set var="_path" value="${pageContext.request.contextPath}"></c:set>
<form id="changeCardForm" style="margin:10;text-align: center;">
	<table width="100%">
		<tr>
			<td>流水号：</td>
			<td>
				<input name="itemid" style="width: 150"/>
			</td>
			<td>原卡号：</td>
			<td>
				<input name="oldcardid" style="width: 150"/>
			</td>
			<td>新卡号：</td>
			<td>
				<input name="newcardid" style="width: 150"/>
			</td>			
			<td align="center">
				<a href="javascript:void(0);" onclick="clearAbaForm()" class="easyui-linkbutton" iconCls="icon-search">清空</a>
			</td>
		</tr>
		<tr>
			<td>操作员：</td>
			<td>
				<input name="creatuserid" style="width: 150"/>
			</td>
			<td>开始日期：</td>
			<td>
				<input class="easyui-datebox" name="startDate" style="width: 150"/>
			</td>
			<td>截止日期：</td>
			<td>
				<input class="easyui-datebox" name="endDate" style="width: 150"/>
			</td>
			<td align="center"><a href="javascript:void(0);" onClick="doSearchAba()" class="easyui-linkbutton" iconCls="icon-search">查询</a></td>
		</tr>
	</table>
</form>
<div id="changeCardTable"></div>
<script>
var jsonList = '${json.mab}';
jsonList = eval('('+jsonList+')');
function returnListJson(val){
	if(val!=''){
	  return jsonList[val].split('-')[0];
	}
}
jQuery(function($){
	$('#changeCardTable').datagrid({
		title:'换卡明细列表',//标题
		method:'post',
		iconCls:'icon-edit',//图标
		singleSelect:true,//多选
		height:428,
		fitColumns: true,//自动调整各列，用了这个属性，下面各列的宽度值就只是一个比例。
		striped: true,//奇偶行颜色不同
		collapsible:false,//可折叠
		sortName: 'itemid', //排序的列
		sortOrder: 'desc', //倒序
		remoteSort: true, //服务器端排序
		idField:'itemid', //主键字段
		queryParams:{}, //查询条件
		pagination:true, //显示分页
		rownumbers:true, //显示行号
		showFooter:true,
		columns:[[
			{field:'itemid',title:'换卡流水号',width:30,sortable:true},
			{field:'oldcardid',title:'原卡号',width:30},
			{field:'newcardid',title:'新卡号',width:30},
			{field:'mabflag',title:'卡损坏原因',width:20,
				formatter:function(value,row,index){return returnListJson(row.mabflag);}
			},
			{field:'selltax',title:'手续费',width:20}
		]],
		toolbar:[{
			text:'导出PDF',
			iconCls:'icon-print',
			handler:function(){
				$('#changeCardForm').attr('method','post');
				$('#changeCardForm').attr('action','${_path}/aba/exportChangeCardForPdf');
				$('#changeCardForm').submit();
			}
		},'-',{
			text:'导出EXCEL',
			iconCls:'icon-print',
			handler:function(){
				$('#changeCardForm').attr('method','post');
				$('#changeCardForm').attr('action','${_path}/aba/exportChangeCardForExcel');
				$('#changeCardForm').submit();
			}
		}],
		onLoadSuccess:function(){
			$('#changeCardTable').datagrid('clearSelections');//一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
		}
	});
});
//表格查询
function doSearchAba(){
	var params = $('#changeCardTable').datagrid('options').queryParams;//先取得 datagrid的查询参数
	var fields =$('#changeCardForm').serializeArray();//自动序列化表单元素为JSON对象
	$.each( fields, function(i, field){
		params[field.name] = field.value;//设置查询参数
	}); 
	
	$('#changeCardTable').datagrid({url:'aba/queryChangeCardList'});
	$('#changeCardTable').datagrid('reload');
}
//清空查询条件
function clearAbaForm(){
	$('#changeCardForm').form('clear');
	doSearchAba();
}
</script>